/**
 * 
 */
package edu.gatech.oad.mule.view;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.io.IOException;
import java.io.InputStream;

import javax.imageio.ImageIO;
import javax.swing.JPanel;

/**
 * Represents the graphics that need to be displayed during an intro phase.
 * @author Natasha
 * 
 */
class IntroPanel extends JPanel {
	private static Image SCREEN_INTRO;

	/**
	 * Constructs a new IntroPanel.
	 * 
	 */
	public IntroPanel(Dimension dimension) {
		try {
			// Attempt to load the graphic for the intro screen.
			ClassLoader classLoader = Thread.currentThread()
					.getContextClassLoader();
			InputStream input = classLoader
					.getResourceAsStream(GraphicsLib.SCREEN_INTRO);
			SCREEN_INTRO = ImageIO.read(input);
			setPreferredSize(dimension);

		} catch (IOException e) {
			System.out.println("ERROR: failed to create IntroPanel");
			e.printStackTrace();
		}
	}

	@Override
	public void paintComponent(Graphics g) {
		// Let UI Delegate paint first, which
		// includes background filling since
		// this component is opaque.

		super.paintComponent(g);
		g.drawImage(SCREEN_INTRO, 0, 0, this.getWidth(), this.getHeight(), null);
	}
}
